home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Enlighten DSM 1.1
/
SGI EnlightenDSM 1.1.iso
/
dec3240
/
install.z
/
install
/
bin
/
start_enl_daemons
< prev
next >
Wrap
Text File
|
1998-06-30
|
10KB
|
449 lines
#!/bin/sh
#
# Script: start_enl_daemons [-continue] [-restart]
#
# Without given the -continue option, start_enl_daemons
# will exit if any component fails to come up.
#
# If passed with the "-restart" option, start_enl_daemons
# will "bounce" all currently running daemons
# (i.e. kill them, then restart them).
#
# Without given the -restart option, start_enl_daemons will
# not start any daemon that is already running.
#
# start_enl_daemons invokes all Enlighten daemons
# (emd, pep, renld, and Events)
#
# Copyright (c) 1990-1998 Enlighten Software Solutions, Inc.
# All Rights Reserved.
#
STARTUP_SECS=5
SHUTDOWN_SECS=10
SMUX_CLEARING_SECS=60
DEFAULT_LOG_LEVEL=0
LOGMIN=0
LOGMAX=4
PATH=/bin:/usr/bin:/usr/sbin:/etc:/usr/ucb:/usr/bsd:/usr/etc:$PATH
export PATH
appName=`basename $0`
hostname=`uname -n`
OS=`uname -s`
REV=`uname -r`
enhancedLicense=
agentmon_option=""
#
# Deal with bsd ps
#
OPTS="-e"
PIDCOLUMN=1
if [ "$OS" = "SunOS" ]; then
case "$REV" in
4.1.* )
OPTS="-gxww" ; export OPTS
PIDCOLUMN=1 ; export PIDCOLUMN
;;
esac
fi
logLevel=$DEFAULT_LOG_LEVEL
while [ "$#" -ne 0 ] ; do
case "$1" in
-c* )
CONTINUE=true
;;
-r* )
RESTART=true
;;
-v )
logLevel=$2
if [ -z "$logLevel" ] ; then
logLevel=$DEFAULT_LOG_LEVEL
echo "$appName: Log level was missing."
else
shift
fi
;;
-v* )
logLevel=`expr "$1" : '-v\([0-9]*\)'`
if [ -z "$logLevel" ] ; then
logLevel=$DEFAULT_LOG_LEVEL
echo "$appName: '$1' is not valid."
fi
;;
*)
echo
echo "$appName is used to invoke all Enlighten daemons."
echo
echo "Usage: $appName [-continue] [-restart] [-v <verbosity level (0-4)>]"
echo " -continue: ignore any start-up errors and invoke all necessary daemons."
echo " -restart: kill old Enlighten daemons before startup."
echo
exit 1
;;
esac
shift
done
if [ $logLevel -lt $LOGMIN ] ; then
logLevel=$LOGMIN
elif [ $logLevel -gt $LOGMAX ] ; then
logLevel=$LOGMAX
fi
if [ $logLevel -ne $DEFAULT_LOG_LEVEL ] ; then
echo "$appName: Log level set to $logLevel."
fi
exit_or_continue(){
if [ ! "$CONTINUE" = "true" ] ; then
exit 1
fi
}
#
# Ensure the user is root
#
USER_ID=`id | tr "\(" "=" | cut "-d=" -f2`
if [ ! $USER_ID = 0 ] ; then
echo
echo "### $appName must be run by the 'root' superuser."
echo " Please login as root and try again."
echo
exit 2
fi
#
# Get a valid key file
#
if [ -z "$ENL_KEYS" -o ! -r "$ENL_KEYS" ] ; then
KEY_FILE=/etc/enlighten
else
KEY_FILE=$ENL_KEYS
fi
if [ ! -r "$KEY_FILE" ] ; then
echo "$appName: Fatal: Could not read file $KEY_FILE." 1>&2
echo "$appName: Reinstall Enlighten on this host." 1>&2
exit 1
fi
#
# Setup ENLIGHTEN.
#
# First try the environment variable. If that is not set properly,
# override the value with $KEY_FILE's value.
#
# If KEY_FILE is missing, '^enlighten=' is missing from KEY_FILE,
# or the directory is missing, exit.
#
if [ ! -d "$ENLIGHTEN" ] ; then
ENLIGHTEN=""
fi
if [ -z "$ENLIGHTEN" ] ; then
ENLIGHTEN=`egrep "^enlighten=" $KEY_FILE | cut "-d=" -f2-`
export ENLIGHTEN
fi
#
# Get EMD_DIR
#
EMD_DIR=`egrep "^emd_dir=" $KEY_FILE | cut "-d=" -f2-`
EMD_HOST=`egrep "^emd_host=" $KEY_FILE | cut "-d=" -f2-`
if [ ! -d "$ENLIGHTEN" -a ! -d "$EMD_DIR" ] ; then
echo "$appName: Could not find an ENLIGHTEN directory." 1>&2
echo "$appName: Please ensure the validity of $KEY_FILE, or reinstall." 1>&2
exit 1
fi
#
# Stop daemons if necessary
#
if [ "$RESTART" = "true" ] ; then
if [ -x $ENLIGHTEN/bin/stop_enl_daemons ] ; then
$ENLIGHTEN/bin/stop_enl_daemons
if [ $? -ne 0 ] ; then
exit_or_continue
fi
else
$EMD_DIR/bin/stop_enl_daemons
if [ $? -ne 0 ] ; then
exit_or_continue
fi
fi
fi
echo
echo "$appName: Starting Enlighten daemons on `date`"
echo
# get a list of IP addresses for this host
# only type inet, not loopback, not down, not broadcast
emdHostKeyIsIPaddr=0
gial=
if [ -x $EMD_DIR/bin/gial ] ; then
gial=$EMD_DIR/bin/gial
fi
if [ ! -z "$gial" ] ; then
for ipaddr in `$gial`
do
if [ "$EMD_HOST" = "$ipaddr" ] ; then
# override the result of the uname if we match
# on an IP address
emdHostKeyIsIPaddr=1
fi
done
fi
#
# Always start license daemons and EMD if this is the emd host
#
if [ $emdHostKeyIsIPaddr -eq 1 -o "$EMD_HOST" = "$hostname" ] ; then
OLD_PID=`ps $OPTS | awk '{print $0, " 0"}'|grep "emdd " | \
egrep -v "enl_post_install|grep" \
| awk '{ print $'$PIDCOLUMN'; }'`
if [ ! -z "$OLD_PID" ] ; then
echo "$appName: EMD is already running [pid $OLD_PID]."
else
if [ -z "$EMD_DIR" ] ; then
echo "$appName: Error: Could not find 'emd_dir' in $KEY_FILE." 1>&2
echo "$appName: Could not start EMD." 1>&2
exit_or_continue
else
if [ ! -x $EMD_DIR/bin/start_emdd ] ; then
echo "$appName: Error: $EMD_DIR/bin/start_emdd was missing." 1>&2
echo "$appName: Could not start EMD." 1>&2
exit_or_continue
else
echo
echo "$appName: Invoking $EMD_DIR/bin/start_emdd..."
export EMD_DIR logLevel
su dbenl -c ". $EMD_DIR/.profile ; $EMD_DIR/bin/start_emdd -v $logLevel" 2>&1
if [ $? -ne 0 ] ; then
echo "$appName: Could not start EMD." 1>&2
exit_or_continue
fi
# Allow EMD to register its RPC services before PEP starts
sleep $STARTUP_SECS
fi
fi
fi
fi
#
# Always start PEP is it is the pep host
#
PEP_host=`cat $KEY_FILE | egrep "^pep_host=" | cut "-d=" -f2-`
if [ "$PEP_host" = "$hostname" ] ; then
OLD_PID=`ps $OPTS | awk '{print $0, " 0"}'|grep "pep " | \
egrep -v "enl_post_install|grep" \
| awk '{ print $'$PIDCOLUMN'; }'`
if [ ! -z "$OLD_PID" ] ; then
echo "$appName: PEP is already running [pid $OLD_PID]."
else
if [ ! -x $ENLIGHTEN/bin/pep ] ; then
echo "$appName: Error: $ENLIGHTEN/bin/pep was missing." 1>&2
echo "$appName: Could not start PEP." 1>&2
exit_or_continue
fi
echo
echo "$appName: Invoking $ENLIGHTEN/bin/pep..."
$ENLIGHTEN/bin/pep -f $ENLIGHTEN/contrib/rules.txt -v $logLevel
sleep $STARTUP_SECS;
PEP_PID=`ps $OPTS | awk '{print $0, " 0"}'|grep "pep " | \
egrep -v "enl_post_install|grep" `
if [ -z "$PEP_PID" ] ; then
echo "$appName: Error: PEP did not start up." 1>&2
exit_or_continue
fi
fi
fi
#
# Start up renld if it was installed
#
if [ -x $ENLIGHTEN/bin/renld ] ; then
OLD_PID=`ps $OPTS | awk '{print $0, " 0"}'|grep "renld " \
| egrep -v "enl_post_install|grep|renldc" \
| awk '{ print $'$PIDCOLUMN'; }'`
if [ ! -z "$OLD_PID" ] ; then
echo "$appName: renld is already running [pid $OLD_PID]."
else
echo
echo "$appName: Invoking $ENLIGHTEN/bin/renld..."
$ENLIGHTEN/bin/renld -v $logLevel
sleep $STARTUP_SECS;
RENLD_PID=`ps $OPTS | awk '{print $0, " 0"}'|grep "renld " | \
egrep -v "enl_post_install|grep|renldc" `
if [ -z "$RENLD_PID" ] ; then
echo "$appName: renld did not start up." 1>&2
exit_or_continue
fi
fi
fi
startAgentENL () {
#
# See if AgentENL is already running
#
OLD_PID=`ps $OPTS | awk '{print $0, " 0"}'|grep "AgentENL " | \
egrep -v "enl_post_install|grep" \
| awk '{ print $'$PIDCOLUMN'; }'`
if [ ! -z "$OLD_PID" ] ; then
echo "$appName: AgentENL is already running [pid $OLD_PID]."
else
#
# Start AgentENL
#
#
# For AIX 4.x, need to explicitly load NFS to load the kernel
# extension objects at system reboot
#
VERS=`uname -v`
if [ $VERS = "4" -a $OS = "AIX" ] ; then
IBM_HOST=yes
if [ ! -x $ENLIGHTEN/bin/LoadChk ] ; then
echo "$appName: Error: The application $ENLIGHTEN/bin/LoadChk" 1>&2
echo "$appName: was missing. Please reinstall Enlighten." 1>&2
exit_or_continue
fi
$ENLIGHTEN/bin/LoadChk;
sleep $STARTUP_SECS
fi
echo "$appName: Invoking $ENLIGHTEN/bin/AgentENL..."
($ENLIGHTEN/bin/AgentENL $ENLIGHTEN/config/AgentENL.config)
sleep $STARTUP_SECS;
AGENTENL_PID=`ps $OPTS | awk '{print $0, " 0"}'|grep "AgentENL " \
| egrep -v "enl_post_install|grep" | awk '{ print $'$PIDCOLUMN'; }'`
if [ -z "$AGENTENL_PID" ] ; then
echo "$appName: Error: AgentENL did not start up." 1>&2
fi
fi
}
start_AgentMon(){
if [ "$logLevel" = "0" ] ; then
$ENLIGHTEN/bin/AgentMon $agentmon_option 2>> $ENLIGHTEN/logs/AgentMon.err
else
$ENLIGHTEN/bin/AgentMon $agentmon_option -d $logLevel 1> /dev/null 2>> $ENLIGHTEN/logs/AgentMon.err &
fi
}
#
# Start up Events if it was installed
#
if [ -x $ENLIGHTEN/bin/AgentMon -a -x $ENLIGHTEN/bin/AgentENL ] ; then
#
# Start AgentENL?
#
configFile=$ENLIGHTEN/config/AgentENL.config
if [ -f $configFile ] ; then
if [ -z "`egrep '^MANAGER' $configFile | grep '(disabled)'`" -a \
-z "`egrep '^COMMUNITY' $configFile | grep '(disabled)'`" ] ; then
startAgentENL
else
echo "$appName: (ENlighten/SNMP functionality is currently disabled.)"
if [ "$OS" = "SCO_SV" -o "$OS" = "AIX" ] ; then
agentmon_option="-s"
fi
fi
fi
#
# See if AgentMon is licensed
#
LM_LICENSE_FILE="@$EMD_HOST" $ENLIGHTEN/bin/alc
status=$?
if [ $status = 0 ] ; then
#
# See if AgentMon is already running
#
OLD_PID=`ps $OPTS | awk '{print $0, " 0"}'|grep "AgentMon " | \
egrep -v "enl_post_install|grep" \
| awk '{ print $'$PIDCOLUMN'; }'`
if [ ! -z "$OLD_PID" ] ; then
echo "$appName: AgentMon is already running [pid $OLD_PID]."
else
#
# Start AgentMon
#
echo
echo "$appName: Invoking $ENLIGHTEN/bin/AgentMon..."
start_AgentMon
sleep $STARTUP_SECS;
#
# Make sure the port is set up with AgentENL before AgentMon starts
#
sleep $STARTUP_SECS;
AGENTMON_PID=`ps $OPTS | awk '{print $0, " 0"}'|grep "AgentMon " \
| egrep -v "enl_post_install|grep" | awk '{ print $'$PIDCOLUMN'; }'`
if [ -z "$AGENTMON_PID" ] ; then
echo "$appName: Error: AgentMon did not start up." 1>&2
exit_or_continue
fi
fi
fi
fi
echo
echo "$appName: Enlighten daemons are active on $hostname."
exit 0